﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/User.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Site.Areas.User.ViewModels.ProductViewModel>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<%@ Import Namespace="SDT.Lib.Paging" %>
<%@ Import Namespace="SDT.Site.Areas.User.ViewModels" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Trang cá nhân
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Header" runat="server">
<%=ViewData["stringTitle"]%>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Message" runat="server">
<%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%> 
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Toolbar" runat="server">
    <%= Html.Toolbar("Thêm mới", "/User/Product/Create", "new")%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="clear"></div>
<form action="/User/Product" id="productForm" name="productForm" method="post">
    <table width="100%" class="tblprice">
        <tr>
            <th width="30px">STT</th>
            <th width="70px"><%=Html.Sort("Mã tin","ID",ViewData["orderDir"].ToString(), ViewData["order"].ToString())%></th>
            <th><%=Html.Sort("Tiêu đề","Title",ViewData["orderDir"].ToString(), ViewData["order"].ToString())%></th>
            <th width="57px">Lượt xem</th>
            <th width="85px"><%=Html.Sort("Ngày hết hạn", "ExpireDate",ViewData["orderDir"].ToString(),ViewData["order"].ToString())%></th>
            <th width="30px">Sửa</th>
            <th width="30px">Xóa</th>
        </tr>
        <%  int i = 1;
            
            foreach (var item in Model.Products)
            {
                var bgcolor = "";                               // Created by VietLV (Sort data - 05/08/2011)
                if (i % 5 == 0) bgcolor = "bgcolor=#F3F3F3";    // Created by VietLV (Sort data - 05/08/2011)
                                    %>
        <tr <%=bgcolor %>>
            <td align="center"><%=i.ToString() %></td>
            <td align="center"><%= item.ID %></td>
            <td>
                <a href="/product/details/<%=item.ID %>/<%=Html.ToUrlFriendly(item.Title)%>"><%=item.Title%></a>
            </td>
            <td align="center"><%= item.nViews %></td>
            
            <%--<td></td>--%>
            <td><%=string.Format("{0:dd/MM/yyyy}",item.ExpireDate)%></td> <%--Modified VietLV (05/08/2011)--%>
            <td align="center">
            <%=Html.ActionImage("Sửa","icon-24-edit.png","User/Product","Edit",new Dictionary<string,object>() {{"id",item.ID}} )%> <%--Modified VietLV (05/08/2011)--%>
            </td>
            <td align="center">
                <%=Html.ActionImage("Xóa","icon-24-delete.png","User/Product","Delete", new Dictionary<string,object>() {{"id",item.ID}} )%>  <%--Modified VietLV (05/08/2011)--%>
            </td>
        </tr>
        <%
            i++;
            } %>
    </table>
    <div class="pagebarUTH f_r">
        Trang <%= Model.Products.PageNumber%>/<%= Model.Products.PageCount%>
        <%= Html.Pager(Model.Products.PageSize, Model.Products.PageNumber, Model.Products.TotalItemCount)%>
        <label>Hiển thị #</label>
        <%
            int[] pageSizeList = { 1, 5, 10, 15, 20, 25, 50, 100 };
        %>
        <%= Html.DropDownList("PageSize", new SelectList(pageSizeList, Model.Products.PageSize), new { onchange = "document.productForm.submit();" })%>
     </div>	
    <%= Html.Hidden("order")%>
    <%= Html.Hidden("orderDir")%>
    <script type="text/javascript">
        function tableOrdering(order, dir) {
            // get form element
            var form = document.productForm;

            // Change talbe order
            form.order.value = order;
            form.orderDir.value = dir;

            // Submit the admin form
            form.submit();
        }                 
    </script>
</form>

</asp:Content>
